package com.jckl.foodathon.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

import com.jckl.foodathon.R;
import com.jckl.foodathon.fragments.HomeFragment;
import com.jckl.foodathon.model.Coordinate;

public class HomeActivity extends FragmentActivity {
	
	private Coordinate coordinate;
	private Menu menu;
	private String storeName;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.acti_home);
		
		FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
		ft.replace(R.id.home_placeholder, new HomeFragment());
		ft.commit();
		
	}
	
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {

		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		this.menu = menu;
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			Toast.makeText(getApplicationContext(), "Settings selected", Toast.LENGTH_SHORT).show();
			return true;
		}
		if (id == R.id.action_preferences) {
			Toast.makeText(getApplicationContext(), "Preferences selected", Toast.LENGTH_SHORT).show();
			return true;
		}
		if (id == R.id.action_store_setup) {
			Intent intent = new Intent(getApplicationContext(), StoreActivity.class);
			startActivity(intent);
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	/***
	 * 
	 * Getter & Setter to share data across fragments
	 * 
	 */
	public Coordinate getCoordinate() {
		return coordinate;
	}
	public void setCoordinate(Coordinate coordinate) {
		this.coordinate = coordinate;
	}
	public Menu getMenu() {
		return menu;
	}
	public void setMenu(Menu menu) {
		this.menu = menu;
	}
	public String getStoreName() {
		return storeName;
	}
	public void setStoreName(String storeName) {
		this.storeName = storeName;
	}
	
	


}
